from hashlib import blake2b
from random import choice
from tabnanny import verbose
from django.db import models

# Create your models here.
class Category(models.Model):
    id=models.AutoField(primary_key=True)
    category_name = models.CharField(max_length=100,verbose_name='分类名称')
    
    def __str__(self):
        return self.category_name
    
    class Meta:
        db_table = 'category'
        verbose_name = '分类管理'
        verbose_name_plural = '分类管理'
        
Region=[
    (1,'中国'),
    (2,'美国'),
    (3,'日本'),
    (4,'韩国'),
    (5,'中国香港'),
    (6,'中国台湾'),
    (7,'中国澳门'),
    (8,'其他'),
]
Quality=[
    (0,'未知'),
    (1,'720P'),
    (2,'1080P'),
    (3,'4k'),
]

Hot=[
    (True,'是'),
    (False,'否'),
]
Top=[
    (True,'是'),
    (False,'否'),
]
Show=[
    (True,'是'),
    (False,'否'),
]
Free=[
    (True,'是'),
    (False,'否'),
]
    
class Movie(models.Model):
    id=models.AutoField(primary_key=True)
    movie_name = models.CharField(max_length=100,verbose_name='电影名称')
    
    release_year = models.IntegerField(verbose_name='上映年份')
    director = models.CharField(max_length=100,verbose_name='导演')
    scriptwriter = models.CharField(max_length=100,verbose_name='编剧')
    actors = models.CharField(max_length=200,verbose_name='演员')
    
    region = models.SmallIntegerField(choices=Region, verbose_name='上映地区')
    types = models.CharField(max_length=100,verbose_name='类型')
    language = models.CharField(max_length=100,verbose_name='语言')
    release_date = models.DateField(verbose_name='上映日期')
    duration = models.CharField(max_length=100,verbose_name='时长（或集数）')
    quality = models.SmallIntegerField(choices=Quality, verbose_name='分辨率')
    alternate_name = models.CharField(blank=True,max_length=100,verbose_name='别名')
    image_url = models.CharField(blank=True,max_length=100,verbose_name='图片URL')
    rate = models.FloatField(verbose_name='评分')
    review = models.TextField(blank=True,verbose_name='影评')
    is_hot=models.BooleanField(choices=Hot,default=False,verbose_name='是否热门')
    is_top=models.BooleanField(choices=Top,default=False,verbose_name='是否置顶')
    subtitle=models.CharField(max_length=100,verbose_name='字幕', blank=True)
    update_info=models.CharField(max_length=100,verbose_name='更新信息', blank=True)
    update_progress=models.CharField(max_length=100,verbose_name='更新进度', blank=True)
    download_info=models.TextField(max_length=50,blank=True,verbose_name='网盘信息')
    is_show=models.BooleanField(choices=Show,default=True,verbose_name='是否显示')
    is_free=models.BooleanField(choices=Free,default=False,verbose_name='是否免费')
    
    category = models.ForeignKey(Category,on_delete=models.CASCADE,verbose_name='电影分类')
    
    def __str__(self):
        return self.movie_name
    
    class Meta:
        db_table = 'movie'
        verbose_name = '电影管理'
        verbose_name_plural = '电影管理'
